package com.ssy.lingxi.purchase.api.enums.onlinebidding;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 在线竞价单工作流内部状态枚举
 * @author wrc
 * @date 2021/1/19
 */
public enum OnlineInteriorWorkStateEnum {
    CANCEL(-1, "已作废"),
    COMPLETE(99, "已完成"),
    TO_BE_APPROVED_BY_BIDDING(18, "待竞价报名"),
    BIDDING_HAS_BEEN_SIGNED_UP(19, "已竞价报名"),
    WAITING_FOR_BIDDING(20, "待竞价"),
    ALREADY_BIDDING(21, "已竞价"),
    ;

    private Integer state;
    private String name;

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public String getName() {
        return LanguageHolder.getName(this.getClass(), this.state);
    }

    public void setName(String name) {
        this.name = name;
    }

    OnlineInteriorWorkStateEnum(Integer state, String name) {
        this.state = state;
        this.name = name;
    }

    public static String getName(Integer state){
        OnlineInteriorWorkStateEnum workEnum = Arrays.stream(OnlineInteriorWorkStateEnum.values()).filter(v -> v.getState().equals(state)).findAny().orElse(null);
        return null == workEnum ? "" : LanguageHolder.getName(OnlineInteriorWorkStateEnum.class, workEnum.getState());
    }


    /**
     * 枚举值集合
     * @return
     */
    public static List<Integer> getCodes(){
        return Arrays.stream(OnlineInteriorWorkStateEnum.values()).map(OnlineInteriorWorkStateEnum::getState).collect(Collectors.toList());
    }

}
